package com.atguigu.tingshu.user.strategy.impl;
import java.util.Date;
import com.google.common.collect.Maps;

import com.atguigu.tingshu.common.constant.SystemConstant;
import com.atguigu.tingshu.model.user.UserPaidAlbum;
import com.atguigu.tingshu.user.mapper.UserPaidAlbumMapper;
import com.atguigu.tingshu.user.strategy.UpdateUserPaidRecordStrategy;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Author  王东剑
 * Created on 24/6/2024 下午8:00
 * Package_name com.atguigu.tingshu.user.strategy.impl
 * Description 专辑购买保存交易信息策略
 */
@Slf4j
@Service
public class UserPaidAlbumStrategyImpl implements UpdateUserPaidRecordStrategy {
	@Autowired
	private UserPaidAlbumMapper userPaidAlbumMapper ;
	@Override
	public void updateUserPaidRecord(UserPaidRecordVo userPaidRecordVo) {
		// 直接存,因为有 orderNo 的唯一索引
		UserPaidAlbum userPaidAlbum = new UserPaidAlbum();
		userPaidAlbum.setOrderNo(userPaidRecordVo.getOrderNo());
		userPaidAlbum.setUserId(userPaidRecordVo.getUserId());
		userPaidAlbum.setAlbumId(userPaidRecordVo.getItemIdList().get(0));
		userPaidAlbumMapper.insert(userPaidAlbum);
	}

	@Override
	public String getItemType() {
		return SystemConstant.ORDER_ITEM_TYPE_ALBUM;
	}
}
